package com.example.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.pojo.CustomerLoss;
import com.example.mapper.CustomerLossMapper;
import com.example.service.ICustomerLossService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jayway.jsonpath.internal.Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author wsl
 * @since 2022-05-06
 */
@Service
public class CustomerLossServiceImpl extends ServiceImpl<CustomerLossMapper, CustomerLoss> implements ICustomerLossService {
    @Autowired
    private CustomerLossMapper customerLossMapper;
    /**
     * 查询所有
     */
    public List<CustomerLoss> selectAll(){
        QueryWrapper<CustomerLoss> wrapper = new QueryWrapper<CustomerLoss>().orderByDesc("id");
        return customerLossMapper.selectList(wrapper);
    }
    /**
     * 无条件分页
     * @return
     */
    public PageInfo<CustomerLoss> electByPager(Integer pageNo, Integer pageSize,String cusName,String cusNo,Integer state){
        PageHelper.startPage(pageNo,pageSize);
        QueryWrapper<CustomerLoss> wrapper=new QueryWrapper<CustomerLoss>().orderByDesc("id");
        wrapper.like(!Utils.isEmpty(cusName),"cus_name",cusName)
                .like(!Utils.isEmpty(cusNo),"cus_no",cusNo)
                .eq(state!=null,"state",state);
        List<CustomerLoss> list=baseMapper.selectList(wrapper);
        return new PageInfo<>(list);
    }
}
